<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Bills" >
                        <f:facet name="header" >                          
                            <h:outputLabel value="PHARMACY BILL SEARCH SALE BILL  "/>
                            <h:panelGrid columns="6" >
                                <h:outputLabel value="From Date"/>
                                <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{billSearch.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >                                                                       
                                </p:calendar>
                                <h:outputLabel value="To Date"/>
                                <p:calendar id="toDate" value="#{billSearch.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >                                                                      
                                </p:calendar>
                                <p:inputText autocomplete="off" id="txtSearch" value="#{billSearch.txtSearch}"  style="width:500px;">
                                    
                                </p:inputText>
                                <p:commandButton id="btnSearch" ajax="false" value="Search" action="#{billSearch.createPharmacyTable()}"/>
                                <p:defaultCommand target="btnSearch"/>

                            </h:panelGrid>
                            <p:watermark value="Bill Id ,NetTotal,Paymentscheme,Paymentmethod,Patient Name or Phone Number" for="txtSearch" />
                        </f:facet>

                        <p:dataTable rowIndexVar="i" id="tblBills" value="#{billSearch.searchBills}" var="bill" 
                                     paginator="true" rows="20"  lazy="true"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                                     rowsPerPageTemplate="5,10,15" style="min-width: 100%;"  >

                            <p:column headerText="No" styleClass="alignTop">
                                <h:outputLabel value="#{i+1}"/>
                            </p:column>

                            <p:column headerText="Bill No"  filterBy="#{bill.deptId}">
                                
                                    <h:outputLabel value="#{bill.deptId}" ></h:outputLabel>
                                 
                            </p:column>                            

                            <p:column headerText="Bill Date" filterBy="#{bill.createdAt}"  >
                                
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yyyy"/>
                                    </h:outputLabel>
                                 
                            </p:column>
                            <p:column headerText="Bill Time" filterBy="#{bill.createdAt}">
                                
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="HH:mm"/>
                                    </h:outputLabel>
                                   
                            </p:column>
                            <p:column headerText="Client" filterBy="#{bill.patient.person.nameWithTitle}">
                                
                                    <h:outputLabel value="#{bill.patient.person.nameWithTitle}" ></h:outputLabel>
                                  
                            </p:column>                           
                            <p:column headerText="Billed By" filterBy="#{bill.creater.webUserPerson.name}"  >
                                
                                    <h:outputLabel value="#{bill.creater.webUserPerson.name}" ></h:outputLabel>
                                
                            </p:column>
                            <p:column headerText="Paymentmethod" filterBy="#{bill.paymentMethod}"  >
                                
                                    <h:outputLabel value="#{bill.paymentMethod}" ></h:outputLabel>
                                   
                            </p:column>
                            <p:column headerText="Paymentscheme" filterBy="#{bill.paymentScheme.name}">
                                
                                    <h:outputLabel value="#{bill.paymentScheme.name}" ></h:outputLabel>
                                  
                            </p:column>

                            <p:column headerText="Gross Value" filterBy="#{bill.total}"  >
                               
                                    <h:outputLabel value="#{bill.total}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                  
                            </p:column>
                            <p:column headerText="Discount" filterBy="#{bill.discount}"  >
                                
                                    <h:outputLabel value="#{bill.discount}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                 
                            </p:column>
                            <p:column headerText="Net Value" filterBy="#{bill.netTotal}"  >
                                
                                    <h:outputLabel value="#{bill.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    
                            </p:column>
                            <p:column headerText="Cancelled User" filterBy="#{bill.cancelledBill.creater.webUserPerson.name}" >
                                
                                    <h:outputLabel rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" ></h:outputLabel>
                                   
                            </p:column>
                            <p:column headerText="Cancelled Date and Time" filterBy="#{bill.cancelledBill.createdAt}">
                                
                                    <h:outputLabel rendered="#{bill.cancelled}" value="#{bill.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yyyy HH:mm:ss"/>
                                    </h:outputLabel>
                                   
                            </p:column>                          

                            <p:column headerText="Comments" >
                                <h:outputLabel rendered="#{bill.refundedBill ne null}" value="#{bill.refundedBill.comments}" >
                                </h:outputLabel>
                                <h:outputLabel  rendered="#{bill.cancelledBill ne null}" value="#{bill.cancelledBill.comments}" >
                                </h:outputLabel>
                            </p:column>
                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
